﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private static string expression = "";//Строка выражения
        string boof1 = "", boof2 = "";//Буферные строки для цифер
        char sing = ' ';//какой знак
        private static bool flagPlusMinus = false;
        public Form1()
        {
            InitializeComponent();
            textBox1.Select();
        }

        private void button1_Click(object sender, EventArgs e)//кнопка "1"
        {
            expression += '1';
            textBox1.Text = expression;
        }

        private void button2_Click(object sender, EventArgs e)//кнопка "2"
        {
            expression += '2';
            textBox1.Text = expression;
        }

        private void button3_Click(object sender, EventArgs e)//кнопка "3"
        {
            expression += '3';
            textBox1.Text = expression;
        }

        private void button4_Click(object sender, EventArgs e)//кнопка "4"
        {
            expression += '4';
            textBox1.Text = expression;
        }

        private void button5_Click(object sender, EventArgs e)//кнопка "5"
        {
            expression += '5';
            textBox1.Text = expression;
        }

        private void button6_Click(object sender, EventArgs e)//кнопка "6"
        {
            expression += '6';
            textBox1.Text = expression;
        }

        private void button7_Click(object sender, EventArgs e)//кнопка "7"
        {
            expression += '7';
            textBox1.Text = expression;
        }

        private void button8_Click(object sender, EventArgs e)//кнопка "8"
        {
            expression += '8';
            textBox1.Text = expression;
        }

        private void button9_Click(object sender, EventArgs e)//кнопка "9"
        {
            expression += '9';
            textBox1.Text = expression;
        }

        private void button10_Click(object sender, EventArgs e)//кнопка "0"
        {
            expression += '0';
            textBox1.Text = expression;
        }

        private void button11_Click(object sender, EventArgs e)//кнопка "."
        {
            expression += '.';
            textBox1.Text = expression;
        }

        private void button12_Click(object sender, EventArgs e)//кнопка "C"
        {
            expression = "";
            textBox1.Text = "";
        }

        private void button13_Click(object sender, EventArgs e)//кнопка "←"
        {
            if (expression.Length > 0)
            {
                if (expression == "sin" || expression == "cos" || expression == "exp" || expression == "fact")
                {
                    expression = "";
                    textBox1.Text = "";
                }
                else
                {
                    expression = expression.Remove(expression.Length - 1, 1).Insert(expression.Length - 1, "");
                    textBox1.Text = expression;
                }
            }
        }

        private void button14_Click(object sender, EventArgs e)//кнопка "±"
        {

        }

        private void button15_Click(object sender, EventArgs e)//кнопка "M+"
        {

        }

        private void button16_Click(object sender, EventArgs e)//кнопка "M-"
        {

        }

        private void button17_Click(object sender, EventArgs e)//кнопка "/"
        {
            expression += '/';
            textBox1.Text = expression;
        }

        private void button18_Click(object sender, EventArgs e)//кнопка "*"
        {
            expression += '*';
            textBox1.Text = expression;
        }

        private void button19_Click(object sender, EventArgs e)//кнопка "-"
        {
            expression += '-';
            textBox1.Text = expression;
        }

        private void button20_Click(object sender, EventArgs e)//кнопка "+"
        {
            expression += '+';
            textBox1.Text = expression;
        }

        private void button21_Click(object sender, EventArgs e)//кнопка "√"
        {
            expression += '√';
            textBox1.Text = expression;
        }

        private void button22_Click(object sender, EventArgs e)//кнопка "˄"
        {
            expression += '^';
            textBox1.Text = expression;
        }

        private void button23_Click(object sender, EventArgs e)//кнопка "="
        {
            
        }

        private void button24_Click(object sender, EventArgs e)//кнопка "%"
        {
            expression += '%';
            textBox1.Text = expression;
        }

        private void button25_Click(object sender, EventArgs e)//кнопка "sin"
        {
            if (expression.Length == 0)
            {
                expression += "sin";
                textBox1.Text = expression;
            }
        }

        private void button26_Click(object sender, EventArgs e)//кнопка "cos"
        {
            if (expression.Length == 0)
            {
                expression += "cos";
                textBox1.Text = expression;
            }
        }

        private void button27_Click(object sender, EventArgs e)//кнопка "exp"
        {
            if (expression.Length == 0)
            {
                expression += "exp";
                textBox1.Text = expression;
            }
        }

        private void button28_Click(object sender, EventArgs e)//кнопка "fact"
        {
            if (expression.Length == 0)
            {
                expression += "fact";
                textBox1.Text = expression;
            }
        }
    }
}
